<!DOCTYPE html>
<html>
<head>
	<title>创建文章</title>

	{{template "include.html"}}
</head>
<body>

{{template "header.html" .}}

<div id="wrap">
	<div class="container">
		<div class="col-sm-7">
			<form action="/article/edit/{{.article.Id}}" method="post">
				<input name="title" class="form-control" value="{{.article.Title}}"  placeholder="请输入文章标题"/>
				<br>
				<textarea name="content" class="form-control" rows="20" placeholder="正文">{{.article.Content}}</textarea>
				<br>
				<input name="tag" class="form-control" placeholder="标签（以逗号分隔）" value="{{range $idx,$val := .article.Tags}}{{if $idx}}, {{end}}{{.Name}}{{end}}">
				<br>
				<input class="btn btn-default" type="submit"/>
			</form>
		</div>
	</div>
</div>


<script type="text/javascript">
	$("form").bind("submit", function(){
		var tmp = ajaxSubmit(this, function(){
			var code = tmp.responseJSON.code;
			var ok = tmp.responseJSON.success;

			//	返回服务器信息
			if ( ok == true ){
				alert("修改成功");
				location.href='/article/{{.article.Id}}';
			}else{
				alert(tmp.responseJSON.content)
			}
        });
        return false;
	})
</script>

</body>
</html>